package xiaoqi.qingyue.api.basic.photo.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import xiaoqi.qingyue.api.basic.photo.mapper.PhotoMapper;
import xiaoqi.qingyue.api.basic.photo.model.entity.Photo;

import java.util.List;

/**
 * @author 92110
 */
@Service
@RequiredArgsConstructor
public class PhotoServiceImpl implements PhotoService {

    private final PhotoMapper photoMapper;

    @Override
    public Photo uploadPhoto(Photo photo) {
        photoMapper.insert(photo);
        return photo;
    }

    @Override
    public List<Photo> getPhotoList() {
        return photoMapper.selectList(new LambdaQueryWrapper<Photo>().eq(Photo::getStatus, '1'));
    }

    @Override
    public List<Photo> getPhotoListAll() {
        return photoMapper.selectList(null);
    }

    @Override
    public void deletePhoto(String id) {
        photoMapper.update(new Photo(id, '0'), new LambdaQueryWrapper<Photo>().eq(Photo::getId, id));
    }
}
